<template>
	<u-navbar :title="title" :safeAreaInsetTop="true" :fixed="true" :placeholder="true">
		<view class="u-nav-slot" slot="left">
			<u-icon name="arrow-left" v-if="back" size="19" @click="backUp"></u-icon>
			<u-line direction="column" v-if="back" :hairline="false" length="16" margin="0 8px"></u-line>
			<u-icon name="home" size="20" @click="backMain"></u-icon>
		</view>
	</u-navbar>
</template>

<script>
	export default {
		name: "shop-nav",
		props: {
			title: {
				// 当前选中的tab index
				type: String,
				default: "首页",
			},
			back: {
				type: Boolean,
				default: true
			}
		},
		methods: {
			backUp() {
				if (getCurrentPages().length > 1) {
					uni.navigateBack({
						delta: 1, //返回层数，2则上上页
					})
				} else {
					uni.navigateTo({
						url: '/pages/shop/index/index'
					})
				}
			},

			backMain() {
				uni.switchTab({
					url: '/pages/main/index/index' // 返回景区首页
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.u-nav-slot {
		display: flex;
		border-radius: 15px;
		border: 1px solid #c6c6c6;
		padding: 3px 8px;
	}
</style>